package cn.cai.pethome.front;

import cn.cai.pethome.base.PreAuthorize;
import cn.cai.pethome.base.constant.Constant;
import cn.cai.pethome.base.dto.LogininfoDto;
import cn.cai.pethome.base.util.PageList;
import cn.cai.pethome.pet.domain.Pet;
import cn.cai.pethome.pet.query.PetQuery;
import cn.cai.pethome.pet.service.IPetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping("/front")
public class FrontController {

    @Autowired
    private IPetService petService;
    /**
     * 前台-分页查询宠物数据 t_pet表
     * 这里的分页查询只能展示当前登录用户所属店铺的数据
     * @param query 查询对象
     * @return PageList 分页对象
     */

    @PostMapping("/petPagelist")
    public PageList<Pet> json(@RequestBody PetQuery query)
    {
        return petService.queryAll(query);
    }

    /**
     * 根据宠物id查询宠物的图片集合和宠物详情数据
     * @param petId
     * @return
     */
    @GetMapping("/loadPetDetail/{petId}")
    public Map<String,Object> loadPetDetail(@PathVariable("petId")Long petId){
        return petService.loadPetDetail(petId);
    }

}
